﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace RBAC.Api.Infaction
{
    public interface IBaseRepositry<T> where T : class
    {
        MyDbContext Context { get; }
        /// <summary>
        /// 获取所以
        /// </summary>
        /// <returns></returns>
        IQueryable<T> GetAll();
        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        Task<int> Add(T item);
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        Task<int> Update(T item);
        /// <summary>
        /// 删除
        /// </summary>
        Task<int> Delete(T item);
        /// <summary>
        /// 反填
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        T Find(int id);
        /// <summary>
        /// 批量添加
        /// </summary>
        /// <param name="items"></param>
        /// <returns></returns>
        Task<int> AddAsync(IEnumerable<T> items);
        /// <summary>
        /// 批量删除
        /// </summary>
        /// <param name="items"></param>
        /// <returns></returns>
        Task<int> DeleteAsync(IEnumerable<T> items);
        /// <summary>
        /// 批量修改
        /// </summary>
        /// <param name="items"></param>
        /// <returns></returns>
        Task<int> UpdateAsync(IEnumerable<T> items);
    }
}
